<template>
  <div>
    <tableComponents
      :pagination="{ currentPage,pageSize, total: list.all_num }"
      @handleCurrentChange="handleCurrentChange"
      :isHaveAdd="true"
      @handleSizeChange="handleSizeChange"
      @sendUserSearch="receive_search"
      :searchData="userSearchData"
      :isHaveExport="false"
      @toAdd="add_data"
    >
      <template v-slot:table>
        <el-table
          ref="multipleTable"
          :data="list.data"
          stripe
          v-loading="loading"
          header-row-class-name="head_color"
          tooltip-effect="dark"
          style="width: 99.8%"
          @selection-change="handleSelectionChange"
          :default-sort="{ prop: 'sort' }"
        >
          <el-table-column type="selection" class="tc" width="35"></el-table-column>
          <!-- <el-table-column label="排序" sortable :sort-method="sorta" align="center" min-width="50">
            <template slot-scope="scope">
              <div class="tab_div">
                <el-input
                  v-model="scope.row.sort"
                  size="mini"
                  autocomplete="off"
                  class="mar_bottom_5"
                  @change="editSort($event,scope.row)"
                ></el-input>
              </div>
            </template>
          </el-table-column>-->

          <el-table-column label="头像" min-width="80" align="center">
            <template slot-scope="scope">
              <div class="user_table">
                <img
                  :src="$fnc.getImgUrl(scope.row.avatar)"
                  style="width:80px;height:80px;border-radius:50%;"
                  alt
                />
              </div>
            </template>
          </el-table-column>

          <el-table-column label="人物详情" min-width="80">
            <template slot-scope="scope">
              <div class="user_table">
                <span>标题：</span>
                <small>{{ scope.row.title || "----" }}</small>
                <br />
                <span>简介：</span>
                <small>{{ scope.row.introduction || "----" }}</small>
                <br />
                <span>分类：</span>
                <small>{{ scope.row.cate_id_cn}}</small>
                <br />
              </div>
            </template>
          </el-table-column>

          <el-table-column label="信息详情" align="center" min-width="100">
            <template slot-scope="scope">
              <div class="user_table">
                <span>学习人数：</span>
                <small>{{ scope.row.pv||0 }}</small>
                <br />
                <span>粉丝数：</span>
                <small>{{ scope.row.fan||0 }}</small>
                <br />
                <span>作品数：</span>
                <small>{{ scope.row.works||0}}</small>
                <br />
                <span>点赞数：</span>
                <small>{{ scope.row.likes||0 }}</small>
                <br />
              </div>
            </template>
          </el-table-column>

          <!-- <el-table-column label="分类" align="center" min-width="50">
            <template slot-scope="scope">
              <div class="tab_div">
                <span>{{ scope.row.cate_id_cn }}</span>
              </div>
            </template>
          </el-table-column>-->

          <el-table-column prop="name" label="是否开启" align="center" min-width="80">
            <template slot-scope="scope">
              <el-switch
                class="zdySwith"
                :width="82"
                v-model="scope.row.show"
                active-color="#1aad19"
                inactive-color="#ffffff"
                active-text="开启"
                inactive-text="禁止"
                active-value="1"
                inactive-value="0"
                @change="getShow($event,scope.row)"
              ></el-switch>
            </template>
          </el-table-column>

          <el-table-column prop="name" label="是否推荐" align="center" min-width="80">
            <template slot-scope="scope">
              <el-switch
                class="zdySwith"
                :width="82"
                v-model="scope.row.is_top"
                active-color="#1aad19"
                inactive-color="#ffffff"
                active-text="开启"
                inactive-text="禁止"
                active-value="1"
                inactive-value="0"
                @change="getIstop($event,scope.row)"
              ></el-switch>
            </template>
          </el-table-column>

          <!-- <el-table-column label="附表字段" align="center" min-width="100">
            <template slot-scope="scope">
              <div class="tab_div" v-for="(item,index) in scope.row.field" :key="index">
                <div>
                  <span>字段标题：</span>
                  <span>{{ item.title }}</span>
                </div>
                <div>
                  <span>字段参数：</span>
                  <span>{{ item.value || '---' }}</span>
                </div>
              </div>
            </template>
          </el-table-column>-->

          <el-table-column label="添加时间" align="center" min-width="120">
            <template slot-scope="scope">{{ scope.row.created_time | getTimeFormat }}</template>
          </el-table-column>

          <el-table-column label="操作" align="center" min-width="160">
            <template slot-scope="scope">
              <el-row class="myblank">
                <el-button
                  :loading="$store.state.isLoading"
                  size="mini"
                  @click="editbtn(scope.row)"
                  type="primary"
                >编辑</el-button>
                <el-button
                  :loading="$store.state.isLoading"
                  size="mini"
                  type="danger"
                  @click="deletebtn(scope.row.id)"
                >删除</el-button>
              </el-row>
            </template>
          </el-table-column>
        </el-table>
      </template>
      <template v-slot:footerLeft>
        <a class="aBtn aBtn_1 aBtn_lan2" @click="deleteLises">删除</a>
      </template>
    </tableComponents>

    <el-dialog
      :close-on-click-modal="false"
      title="添加"
      class="tl size_13"
      width="800px"
      @close="closeDia"
      :visible.sync="dialogFormVisible"
    >
      <el-form :model="live_single" label-width="120px">
        <el-form-item label="分类">
          <el-col :span="12">
            <el-select @change="getTitle" v-model="live_single.selTitle" placeholder="请选择分类">
              <el-option
                v-for="(item, index) in charList"
                :key="index"
                :label="item.title"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="标题：">
          <el-col :span="16">
            <el-input
              type="text"
              :rows="6"
              clearable
              placeholder="请输入标题"
              v-model="live_single.title"
              autocomplete="off"
            ></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="图片" prop="avatar">
          <el-col :span="10">
            <el-input v-model="live_single.avatar" autocomplete="off" class="mar_bottom_5"></el-input>
            <uploadpic
              :piclink="live_single.avatar"
              :width="150"
              :height="150"
              :is_more="false"
              @send_pic="onSuccess"
            ></uploadpic>
          </el-col>
        </el-form-item>

        <el-form-item label="简介：">
          <el-col :span="16">
            <el-input
              type="textarea"
              :rows="6"
              clearable
              placeholder="请输入"
              v-model="live_single.introduction"
              autocomplete="off"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item v-for="(item,index) in fieldList" :key="item.id" :label="item.title">
          <el-col :span="16">
            <!-- {{fieldList}} -->
            <div v-if="item.types == '1'">
              <el-col :span="16">
                <el-input
                  type="text"
                  :rows="6"
                  clearable
                  placeholder="请输入"
                  v-model="myText"
                  autocomplete="off"
                ></el-input>
              </el-col>
            </div>
            <div v-else-if="item.types == '2'">
              <el-radio-group v-model="myRadio">
                <el-radio v-for="(itemS,indexS) in formatData(item)" :key="indexS" :label="itemS"></el-radio>
              </el-radio-group>
              <!-- <el-radio-group v-model="myRadio">
                <el-radio
                  v-for="ItemS in formatData(item)"
                  :key="ItemS"
                  :label="ItemS"
                  v-model="Item[Index]"
                ></el-radio>
              </el-radio-group>-->
            </div>
            <div v-else-if="item.types == '3'">
              <el-checkbox-group v-model="myCheck">
                <!-- <el-checkbox
                  v-for="(ItemS,IndexS) in parArr[Index]"
                  :key="ItemS[IndexS]"
                  :label="ItemS"
                ></el-checkbox>-->
                <el-checkbox
                  v-for="(itemS,indexS) in parArr[index]"
                  :key="itemS[indexS]"
                  :label="itemS"
                ></el-checkbox>
              </el-checkbox-group>
            </div>
            <div v-else-if="item.types == '4'">
              <el-col :span="12">
                <el-select v-model="SELTitle" @change="selchange" placeholder="请选择">
                  <el-option
                    v-for="(itemS, indexS) in parArr[index]"
                    :key="indexS"
                    :label="itemS"
                    :value="itemS"
                  ></el-option>
                </el-select>
              </el-col>
            </div>
            <div v-else-if="item.types == '5'">
              <el-col :span="20">
                <el-date-picker
                  style="width:310px"
                  size="large"
                  v-model="auction_open_time"
                  type="datetime"
                  placeholder="选择时间"
                ></el-date-picker>
                <span style="padding-left:10px;"></span>
              </el-col>
            </div>
            <div v-else-if="item.types == '6'">
              <el-col :span="10">
                <el-input v-model="live_single.avatarImg" autocomplete="off" class="mar_bottom_5"></el-input>
                <uploadpic
                  :piclink="live_single.avatarImg"
                  :width="150"
                  :height="150"
                  :is_more="false"
                  @send_pic="getSuccess($event,item,index)"
                ></uploadpic>
              </el-col>
            </div>
            <div v-else-if="item.types == '7'">
              <el-col :span="16">
                <el-input
                  type="textarea"
                  :rows="6"
                  clearable
                  placeholder="请输入"
                  v-model="myTextarea"
                  autocomplete="off"
                ></el-input>
              </el-col>
            </div>
          </el-col>
        </el-form-item>

        <el-form-item class="tc">
          <el-button
            :loading="$store.state.isLoading"
            type="primary"
            @click="addlive(live_single)"
          >提 交</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 修改 -->
    <el-dialog
      :close-on-click-modal="false"
      title="修改"
      class="tl size_13"
      width="800px"
      @close="closeEdit"
      :visible.sync="editShow"
    >
      <el-form :model="live_single" label-width="120px">
        <el-form-item label="分类">
          <el-col :span="12">
            <el-input
              v-model="live_single.cate_id_cn"
              disabled
              autocomplete="off"
              class="mar_bottom_5"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="标题：">
          <el-col :span="16">
            <el-input
              type="text"
              :rows="6"
              clearable
              placeholder="请输入标题"
              v-model="live_single.title"
              autocomplete="off"
            ></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="图片" prop="avatar">
          <el-col :span="10">
            <el-input v-model="live_single.avatar" autocomplete="off" class="mar_bottom_5"></el-input>
            <uploadpic
              :piclink="live_single.avatar"
              :width="150"
              :height="150"
              :is_more="false"
              @send_pic="onSuccess"
            ></uploadpic>
          </el-col>
        </el-form-item>

        <el-form-item label="简介：">
          <el-col :span="16">
            <el-input
              type="textarea"
              :rows="6"
              clearable
              placeholder="请输入"
              v-model="live_single.introduction"
              autocomplete="off"
            ></el-input>
          </el-col>
        </el-form-item>

        <!-- 其它 -->
        <el-form-item v-for="(Item,Index) in otherRows" :key="Item.id" :label="Item.title">
          <el-col :span="16">
            <!-- {{otherRows}} -->
            <div v-if="Item.types == '1'">
              <el-col :span="16">
                <el-input
                  type="text"
                  :rows="6"
                  clearable
                  placeholder="请输入"
                  v-model="myText"
                  autocomplete="off"
                ></el-input>
              </el-col>
            </div>
            <div v-else-if="Item.types == '2'">
              <el-radio-group v-model="myRadio">
                <el-radio
                  v-for="ItemS in parArr[Index]"
                  :key="ItemS"
                  :label="ItemS"
                  v-model="Item[Index]"
                >{{ ItemS }}</el-radio>
              </el-radio-group>
            </div>
            <div v-else-if="Item.types == '3'">
              <!-- <el-checkbox-group :v-model="myCheck">
                <el-checkbox
                  v-for="(ItemS,IndexS) in parArr[Index]"
                  :key="ItemS[IndexS]"
                  :label="ItemS"
                  :v-model="myCheck"
                ></el-checkbox>
              </el-checkbox-group>-->
              <el-checkbox-group v-model="myCheck">
                <!-- <el-checkbox
                  v-for="(ItemS,IndexS) in parArr[Index]"
                  :key="ItemS[IndexS]"
                  :label="ItemS"
                ></el-checkbox>-->
                <!-- {{parArr[index]}}999 -->
                <el-checkbox
                  v-for="(itemS,indexS) in parArr[Index]"
                  :key="itemS[indexS]"
                  :label="itemS"
                >{{itemS}}</el-checkbox>
              </el-checkbox-group>
            </div>
            <div v-else-if="Item.types == '4'">
              <el-col :span="12">
                <el-select v-model="SELTitle" placeholder="请选择">
                  <el-option
                    v-for="(ItemS, IndexS) in parArr[Index]"
                    :key="ItemS[IndexS]"
                    :label="ItemS"
                    :value="ItemS"
                  ></el-option>
                </el-select>
              </el-col>
            </div>
            <div v-else-if="Item.types == '5'">
              <el-col :span="20">
                <el-date-picker
                  style="width:310px"
                  size="large"
                  v-model="auction_open_time"
                  type="datetime"
                  placeholder="选择时间"
                ></el-date-picker>
              </el-col>
            </div>
            <div v-else-if="Item.types == '6'">
              <el-col :span="10">
                <el-input v-model="selImg[Index]" autocomplete="off" class="mar_bottom_5"></el-input>
                <uploadpic
                  :index="Index"
                  :piclink="selImg[Index]"
                  :width="150"
                  :height="150"
                  :is_more="false"
                  @send_pic="getSuccess($event,Item,Index)"
                ></uploadpic>
              </el-col>
            </div>
            <div v-else-if="Item.types == '7'">
              <el-col :span="16">
                <el-input
                  type="textarea"
                  :rows="6"
                  clearable
                  placeholder="请输入"
                  v-model="myTextarea"
                  autocomplete="off"
                ></el-input>
              </el-col>
            </div>
          </el-col>
        </el-form-item>

        <el-form-item class="tc">
          <el-button
            :loading="$store.state.isLoading"
            type="primary"
            @click="editlive(live_single)"
          >提 交</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import uploadpic from "@/components/page/pic/up_pic";
import { characterinfoSearchData } from "@/assets/js/searchData/searchData"; // 引入搜索的数据
export default {
  data() {
    return {
      userSearchData: characterinfoSearchData,
      dialogFormVisible: false,
      myCheck: [],
      myRadio: 15,
      myTextarea: "",
      myText: "",
      live_single: {
        avatar: "",
        field: [],
        cate_id: "",
        iden: "",
        avatarImg: "",
        show: "",
        is_top: "",
        cate_id_cn: "",
      },
      fieldValue: [],
      auction_open_time: new Date(),
      auction_openTime: "",
      current: "",
      loading: false,
      list: [],
      pageSize: 10,
      currentPage: 1,
      searchAll: {},
      row: {},
      multipleSelection: [],
      charList: [],
      fieldList: [],
      parArr: [],
      SELTitle: "",
      createTime: [],
      formInline: {
        created_time_begin: "",
        created_time_end: "",
        oid: "",
        is_check: "",
      },
      otherRows: [],
      editShow: false,
      selImg: {},
      addId: "",
      addInfo: {
        text: "",
      },
    };
  },
  components: {
    uploadpic,
  },
  watch: {
    createTime(val) {
      if (val != null) {
        this.formInline.created_time_begin = this.$fnc.phptime(val[0]);
        this.formInline.created_time_end = this.$fnc.phptime(val[1]);
      } else {
        this.formInline.created_time_begin = "";
        this.formInline.created_time_end = "";
      }
    },
    // auction_open_time(val) {
    //   console.log("ttttt", val);
    //   var time = val.getTime();
    //   // this.auction_open_time = this.$fnc.phptime(time);
    //   // this.auction_open_time = time;
    // },
    // auction_openTime(val) {
    //   console.log("aaaaaaa", val);
    //   var time = val.getTime();
    //   console.log("axxxx", time);
    //   console.log("123", time.toString());
    //   // this.auction_open_time = this.$fnc.phptime(time);
    //   // this.auction_openTime = time;
    // },
  },
  methods: {
    formatData(value) {
      return value.parameter.split("@");
    },
    checkBd() {},
    closeEdit() {
      // this.fieldList.length = 0;
      this.auction_open_time = "";
    },
    closeDia() {
      // this.fieldList.length = 0;
      this.auction_openTime = "";
    },
    toTypes(type) {
      if (type == "1") {
        return "文本框";
      } else if (type == "2") {
        return "单选";
      } else if (type == "3") {
        return "多选";
      } else if (type == "4") {
        return "下拉";
      } else if (type == "5") {
        return "时间";
      } else if (type == "6") {
        return "图片";
      } else if (type == "7") {
        return "文本域";
      }
    },
    sorta(a, b) {
      return b - a;
    },
    // sortNew(index, row) {
    //   var params = {};
    //   params = row;
    //   params.id = row.id;
    //   params.sort = row.sort;
    //   this.$api.getPage.edit_livepresent(params).then((res) => {
    //     if (res.data.code == 200 && res.data.result) {
    //       return;
    //     } else {
    //       this.$fnc.alertError(res.data.code_desc, res.data.result); //失败弹出框
    //     }
    //   });
    // },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

    deletebtn(id) {
      //删除
      this.$swal({
        title: "您确定要删除这些信息吗",
        text: "删除后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要删除",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          this.$api.getCharacter.characterDel({ id_str: id }).then((res) => {
            if (res.data.code == 200) {
              this.$swal("删除成功！", "您已经删除了这条信息。", "success");
              this.getNewsAll(this.searchAll);
            } else {
              this.$swal("删除失败！", res.data.result, "error");
              this.getNewsAll(this.searchAll);
            }
          });
        }
      });
    },
    deleteLises() {
      //批量删除
      var str = "";
      if (this.multipleSelection.length <= 0) {
        this.$message.error("未选择批量删除");
      } else {
        for (var i in this.multipleSelection) {
          str += this.multipleSelection[i].id + "@";
        }
        str = str.slice(0, -1);
        this.$swal({
          title: "您确定要删除这些信息吗",
          text: "删除后将无法恢复，请谨慎操作！",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "是的，我要删除",
          cancelButtonText: "容我三思",
        }).then((willDelete) => {
          if (willDelete.value) {
            var data = { id_str: str };
            this.$api.getCharacter.characterDel(data).then((res) => {
              if (res.data.code == 200) {
                this.$swal("删除成功！", "您已经删除了这些信息。", "success");
                this.$store.dispatch("getShopsAll", this.searchAll);
                this.getNewsAll(this.searchAll);
              } else {
                this.$swal("删除失败！", "出错啦！", "error");
              }
            });
          }
        });
      }
    },
    add_data() {
      this.live_single = {
        title: "",
        avatar: "",
        avatarImg: "",
        price: "0",
        selTitle: "",
        show: "",
        is_top: "",
        cate_id_cn: "",
      };
      this.dialogFormVisible = true;
    },
    onSuccess(pic, index) {
      console.log(pic, index);
      this.live_single.avatar = pic;
    },
    getSuccess(pic, index, it) {
      console.log("aaaa", index);
      console.log("helllo", it);
      console.log(pic, index);
      this.selImg[it] = pic;

      console.log(this.selImg);
      // this.$set(this.selImg, "img", pic);
      this.$set(this.live_single, "avatarImg", pic);
      // this.live_single.avatarImg = pic;
      console.log(this.live_single);
    },
    getTitle(params) {
      this.addId = params;
      console.log(params);
      this.getCharacterNewsAll();
    },
    getIstop(val, row) {
      var params = {};
      params.id = row.id;
      params.title = row.title;
      params.introduction = row.introduction;
      params.is_top = row.is_top;
      params.show = val;
      this.updata(params);
    },
    editSort(val, row) {
      var params = {};
      params.id = row.id;
      params.title = row.title;
      params.introduction = row.introduction;
      params.is_top = row.is_top;
      params.sort = row.sort;
      params.show = row.show;
      this.updata(params);
    },
    getShow(val, row) {
      var params = {};
      params.id = row.id;
      params.title = row.title;
      params.introduction = row.introduction;
      params.show = val;
      this.updata(params);
    },
    updata(row, bool) {
      var params = {};
      params = row;
      this.$api.getCharacter.topShow(params).then((res) => {
        if (res.data.status == 1 && res.data.code == 200) {
          // if (bool) {
          this.$swal("修改成功！", "您已经修改了这条数据。", "success");
          // }
          //  this.$message.success('提交成功');
        } else {
          this.$swal("修改失败！", res.data.result, "error");
        }
      });
    },
    selchange() {
      console.log(this.SELTitle);
    },
    addlive(item) {
      console.log("aaa");
      console.log(item);
      let params = {};
      // if (item.field) {
      //   delete item.field;
      // }
      params.cate_id = this.addId;
      params.title = item.title;
      params.avatar = item.avatar;
      params.introduction = item.introduction;
      // console.log(params);
      item.field.map((item, index) => {
        if (item.types == 1) {
          params[item.iden] = this.myText;
        } else if (item.types == 2) {
          params[item.iden] = this.myRadio;
        } else if (item.types == 3) {
          params[item.iden] = this.myCheck.join("@");
        } else if (item.types == 4) {
          params[item.iden] = this.SELTitle;
        } else if (item.types == 5) {
          console.log(this.auction_open_time);
          params[item.iden] = this.auction_open_time.getTime();
        } else if (item.types == 6) {
          // let img =
          params[item.iden] = this.selImg[index];
          // console.log("mmmmmmm", img);
        } else if (item.types == 7) {
          params[item.iden] = this.myTextarea;
        }
      });
      console.log(params);
      // 添加
      // this.getCharacterNewsAll();
      // params = item;
      this.$api.getCharacter.characterSaveadd(params).then((res) => {
        console.log(res);

        if (res.data.code == 200) {
          this.parArr = [];
          this.dialogFormVisible = false;
          this.$swal("添加成功！", "您已经添加了这条数据。", "success");
          this.getNewsAll(this.searchAll);
        } else {
          this.$swal("添加失败！", res.data.result, "error");
        }
      });
    },
    formatTime(value) {
      console.log("vvvvv", value);
      return new Date(Number(value));
    },
    // 编辑
    editlive(item) {
      // this.live_single = {};
      var params = {};
      params.id = item.id;
      params.title = item.title;
      params.introduction = item.introduction;
      // console.log("file", item.field);
      let i = 0;
      console.log(this.otherRows);
      item.field.map((item, index) => {
        if (item.types == 1) {
          params[item.iden] = this.myText;
        } else if (item.types == 2) {
          params[item.iden] = this.myRadio;
        } else if (item.types == 3) {
          params[item.iden] = this.myCheck.join("@");
        } else if (item.types == 4) {
          params[item.iden] = this.SELTitle;
        } else if (item.types == 5) {
          console.log(this.auction_open_time);
          params[item.iden] = this.auction_open_time.getTime();
        } else if (item.types == 6) {
          // let img =
          params[item.iden] = this.selImg[index];
          // console.log("mmmmmmm", img);
        } else if (item.types == 7) {
          params[item.iden] = this.myTextarea;
        }
      });
      this.$api.getCharacter.characterSaveEdit(params).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          this.$swal("修改成功！", "您已经修改了这条数据。", "success");
          this.editShow = false;
          this.getNewsAll(this.searchAll);
        } else {
          this.$swal("修改失败！", res.data.result, "error");
        }
      });
      console.log(params);
    },
    // 编辑按钮
    editbtn(item) {
      this.parArr = [];
      this.otherRows = item.field;
      this.live_single = item;
      console.log(this.otherRows);

      this.$api.getCharacter
        .getCharacterFieldList({ id: item.cate_id })
        .then((res) => {
          if (res.data.code == 200) {
            this.fieldList = res.data.result;
            this.live_single.field = [];
            this.fieldList.forEach((item, i) => {
              this.parArr.push(item.parameter.split("@"));
              var obj = {
                iden: item.iden,
                title: item.title,
                types: item.types,
                value: item.value,
              };
              this.live_single.field.push(obj);
            });
          }

          this.loading = false;
        });

      this.loading = false;
      this.editShow = true;
      console.log("pararr", this.parArr);
      this.otherRows.map((item, index) => {
        if (item.types == 1) {
          this.myText = item.vaule;
          console.log("11", this.myText);
        } else if (item.types == 2) {
          this.myRadio = item.vaule;
          console.log(22, this.myRadio);
        } else if (item.types == 3) {
          this.myCheck = item.vaule.split("@");
          console.log(33, this.myCheck);
        } else if (item.types == 4) {
          this.SELTitle = item.vaule;
          console.log(44, this.SELTitle);
        } else if (item.types == 5) {
          this.auction_open_time = new Date(Number(item.vaule));
          console.log(55, this.auction_open_time);
        } else if (item.types == 6) {
          // let img =
          this.selImg[index] = item.vaule;
          console.log(66, this.selImg);
          // console.log("mmmmmmm", img);
        } else if (item.types == 7) {
          this.myTextarea = item.vaule;
          console.log(77, this.myTextarea);
        }
        // console.log("parrrrr");
      });
    },

    receive_search(obj) {
      console.log(obj);
      this.searchAll = obj;
      this.getNewsAll(obj);
    },
    getNewsAll(data) {
      this.loading = true;
      var params = {};
      data = data || {};
      params = data;
      this.$api.getCharacter.getCharacterList(params).then((res) => {
        console.log(res, "121212");
        if (res.data.code == 200) {
          this.list = res.data.result;
          this.$store.dispatch("getcarInfoCate", this.list);
        }
        this.loading = false;
      });
    },
    getCharacterNewsAll() {
      this.$api.getCharacter.getCharacterCateList().then((res) => {
        if (res.data.code == 200) {
          this.charList = res.data.result;
          for (let i = 0; i < this.charList.length; i++) {
            if (this.live_single.selTitle === this.charList[i].id) {
              var id = this.charList[i].id;
              this.live_single.cate_id = this.charList[i].id;
              this.$api.getCharacter
                .getCharacterFieldList({ id })
                .then((res) => {
                  if (res.data.code == 200) {
                    this.fieldList = res.data.result;
                    this.live_single.field = this.fieldList;
                    for (let j = 0; j < this.fieldList.length; j++) {
                      this.parArr.push(this.fieldList[j].parameter.split("@"));
                    }
                    // console.log(this.parArr, "123456789");
                  }
                  this.loading = false;
                });
            }
          }
        }
        this.loading = false;
      });
    },
    handleSizeChange(val) {
      var params = this.searchAll;
      params.page = "";
      params.page_size = val;
      this.getNewsAll(params);
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      var params = this.searchAll;
      params.page = val;
      params.page_size = this.pageSize;
      this.getNewsAll(params);
    },

    // reload() {
    //   this.getNewsAll(this.searchAll);
    // },
  },
  // beforeCreate() {},
  created() {
    this.getNewsAll();
    this.getCharacterNewsAll();
  },
  // computed: {},
};
</script>

<style lang="less" scoped>
.myblank button {
  margin: 5px 5px 0 0;
}
.tab_div > div {
  margin: 0 auto;
}
</style>
